

ifeq ($(OS),Windows_NT)

else

endif 


START_TIME := $(shell cat /proc/uptime | awk -F "." '{print $$1}') # Makefile进入，获取时间戳


all:sim showruntime

help:
	@echo "---------------------------------------------------------------"
	@echo "make               sim and showruntime"
	@echo "make sim           sim"
	@echo "make wave          watch wave"
	@echo "make filelist      creat filelist"
	@echo "---------------------------------------------------------------"



sim: 
	@mkdir -p build
	@iverilog -o build/tb.vvp -I./rtl -y ./rtl    tb.v 
	cd build && vvp tb.vvp -lxt2 


filelist:
	@mkdir -p build
	@iverilog -M build/deps.txt -o build/tb.vvp -I./rtl -y ./rtl    ./rtl/cbb_dividers.v 
	@cat build/deps.txt | sort -u |xargs realpath  > build/filelist.txt
	@sed -i 's/\/cygdrive\/\([a-z]\)/\1:/' build/filelist.txt 
	@rm -rf build/deps.txt
	@echo "creat filelist success!The filelist path is (build/filelist.txt)"
	

wave:
	cd build && gtkwave wave.lxt2 &

showruntime:
	@current_time=`cat /proc/uptime | awk -F "." '{print $$1}'`; \
	time_interval=`expr $${current_time} - $(START_TIME)`; \
	runtime=`date -u -d @$${time_interval} +%Hh:%Mm:%Ss`; \
	echo "runtime: $${runtime} "


clean:
	@rm -rf build 



